package com.wang.designpattern.factory.simplefactory.pizzastore.store;

import com.wang.designpattern.factory.simplefactory.pizzastore.pizza.CheesePizza;
import com.wang.designpattern.factory.simplefactory.pizzastore.pizza.GreekPizza;
import com.wang.designpattern.factory.simplefactory.pizzastore.pizza.PepperPizza;
import com.wang.designpattern.factory.simplefactory.pizzastore.pizza.Pizza;

/**
 * 静态工厂类
 */
public class StaticFactory {
    /**
     * 使用静态工厂模式订购披萨
     * @param orderType
     * @return
     */
    public static Pizza orderPizza(String orderType) {
        System.out.println("使用静态工厂模式");
        Pizza pizza = null;
        if (orderType.equals("cheese")) {
            pizza = new CheesePizza();
            pizza.setName("奶酪披萨");
        } else if (orderType.equals("greek")) {
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        } else if (orderType.equals("pepper")) {
            pizza = new PepperPizza();
            pizza.setName("胡椒披萨");
        }
        return pizza;
    }
}
